package lmscript.postscript.syntax;

import lmscript.postscript.syntax.stack.OperandStack;

public class PSComposite extends PSObject {

	public final static int UNLIMITED = 3;
	public final static int READ_ONLY = 2;
	public final static int EXECUTE_ONLY = 1;
	public final static int NONE = 0;

	private int access = UNLIMITED;

	public PSComposite(String name, int type) {
		super(name, type);
	}

	public boolean accessWrite() {
		return access >= UNLIMITED;
	}

	public boolean accessRead() {
		return access >= READ_ONLY;
	}

	public boolean accessExecute() {
		return access >= EXECUTE_ONLY;
	}

	public boolean changeAccess(int newAccess) {
		if (newAccess > access) {
			return false;
		}
		access = newAccess;
		return true;
	}
	
	public String getTypeString() {
		return super.getTypeString() + ":composite"; 
	}

	@Override
	public boolean execute(OperandStack os) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected boolean check(OperandStack os) {
		return true;
	}
}
